<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var num1 = [1, 3]
        var num2 = [2, 4]
        var findMedianSortedArrays = function (nums1, nums2) {
            var arr = nums1.concat(nums2);
            arr.sort((a, b) => a - b);
            console.log(arr);
            if (arr.length % 2 == 1) {
                console.log("dan");
                var mid = Math.floor(arr.length / 2);
                console.log(arr)
                return arr[mid];
            } else {
                console.log("shuang");
                var mid = arr.length / 2;
                console.log( (arr[mid-1]+arr[mid])/2)
                return (arr[mid] + arr[mid + 1]) / 2
            }
        };
        findMedianSortedArrays(num1, num2)
    </script>
</body>

</html>